//
//  NSDictionary+Property.m
//  Express
//
//  Created by lhongl on 2025/9/26.
//  Copyright © 2025 QM. All rights reserved.
//

#import "NSDictionary+Property.h"

@implementation NSDictionary (Property)

- (void)props{

    NSMutableString *property = [NSMutableString string];

    [self enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
        NSString *code;
        if ([obj isKindOfClass:[NSString class]]) { //字符串

            code = [NSString stringWithFormat:@"///\n@property (nonatomic, copy) NSString *%@;",key];

        }else if ([obj isKindOfClass:NSClassFromString(@"__NSCFBoolean")]){ //BOOL

            code = [NSString stringWithFormat:@"///\n@property (nonatomic, assign) BOOL %@;",key];

        }else if ([obj isKindOfClass:[NSNumber class]]){ //int

            code = [NSString stringWithFormat:@"///\n@property (nonatomic, assign) NSInteger %@;",key];

        }else if ([obj isKindOfClass:[NSArray class]]){ //数组

            code = [NSString stringWithFormat:@"///\n@property (nonatomic, strong) NSArray *%@;",key];

        }else if ([obj isKindOfClass:[NSDictionary class]]){ //字典

            code = [NSString stringWithFormat:@"///\n@property (nonatomic, strong) NSDictionary *%@;",key];

        }else{

            code = [NSString stringWithFormat:@"///\n@property (nonatomic, copy) NSString *%@;",key];
        }
        if (code.length != 0) {
            [property appendFormat:@"\n%@\n",code];
        }
    }];

    NSLog(@"propertyLog========\n%@",property);
}

@end
